using System;
using System.Collections.Generic;
using Rogan.Utility.Common;

namespace Rogan.Data
{
    /// <summary>
    /// Select Expression
    /// </summary>
    [Serializable]
    public class SelectExpression : IDbExpression, ICloneable<SelectExpression>, ITableResetable
    {
        public DbExpressionType ExpressionType
        {
            get
            {
                return DbExpressionType.Select;
            }
        }
        public List<Field> Fields
        {
            get;
            set;
        }
        public SelectExpression()
            : this(null)
        {
        }

        public SelectExpression(Field[] fields)
        {
            if (Fields == null)
            {
                Fields = new List<Field>();
            }
            if (fields != null && fields.Length > 0)
            {
                for (int i = 0; i < fields.Length; i++)
                {
                    Field item = fields[i];
                    Fields.Add(item);
                }
            }
        }
        public SelectExpression Clone()
        {
            return DataHelper.Clone(this) as SelectExpression;
        }
        public void SetTable(string tName)
        {
            if (Fields != null)
            {
                foreach (Field current in Fields)
                {
                    current.SetTableName(tName);
                }
            }
        }
    }
}
